package net.huashitong.msgboard.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.msgboard.entity.MsgBoard;
import net.huashitong.msgboard.filter.MsgBoardFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MsgBoardDao extends StringDao<MsgBoard> {
    public List<MsgBoard> query(MsgBoardFilter filter)
    {
        GenericQuery query = createQuery("obj");
        if (StringUtils.isNotBlank(filter.getGoodName())) {
            query.append(" and obj.goodName like :goodName");
            query.setParam("goodName", StringUtils.getLikewords(filter.getGoodName()));
        }
        return query.listResult(filter);

    }
}
